/********************************************************************************
 * Project Name		[JavaSE_Fundamentals]
 * File Name     	[TestColor.java]
 * Creation Date 	[2015-01-01]
 * 
 * Copyright© ge.y.yang@gmail.com All Rights Reserved
 * 
 * Work hard, play harder, think big and keep fit
 ********************************************************************************/
package swing.awt;

import java.awt.Color;
import java.awt.EventQueue;
import java.awt.Graphics;
import java.awt.SystemColor;

import javax.swing.JFrame;
import javax.swing.JPanel;

/**
 * @author 不落的太阳(Sean Yang aka ShortPeace)
 * @version 1.0
 * @since jdk 1.8
 * 
 */
public class TestColor {

	public static void main(String[] args) {
		EventQueue.invokeLater(new Runnable() {
			@Override
			public void run() {
				ColorFrame frame = new ColorFrame();
				frame.setVisible(true);
				frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
				frame.setResizable(false);
			}
		});
	}
}

/**
 * 
 * @author 不落的太阳(Sean Yang aka ShortPeace)
 * @version 1.0
 * @since jdk 1.8
 *
 */
class ColorFrame extends JFrame {

	private static final long serialVersionUID = 8733671404046904599L;

	public ColorFrame() {
		this.setSize(800, 500);
		this.setTitle("Java Color");
		this.setLocationByPlatform(true);
		// 设置背景色
		this.setBackground(SystemColor.window);
		// 设置前景色
		this.setForeground(Color.BLUE);

		this.getContentPane().add(new JPanel() {
			private static final long serialVersionUID = 9120162495174989168L;

			@Override
			protected void paintComponent(Graphics g) {
				g.drawString("Default Color Testing", 300, 100);

				g.setColor(Color.RED);
				g.drawString("Red Color Testing", 300, 200);

				Color color = g.getColor();
				// 使颜色更加明亮
				color.brighter().brighter().brighter();
				g.setColor(color);
				g.drawString("Deep Color Testing", 300, 300);
			}
		});
	}
}